//
// Top menu
// --------------------------------------------------

#top-menu {
  $top-menu-padding-vertical:   $padding-small-vertical + 1px;
  $top-menu-padding-horizontal: $padding-side;
  @extend %clearfix;
  box-sizing: border-box;
  padding: $top-menu-padding-vertical $top-menu-padding-horizontal;
  background: $top-menu-bg;
  color: $top-menu-text;
  font-size: $font-size-small;

  @if $top-menu-collapse {
    $toggler-position-v:    $top-menu-padding-vertical + 1px;
    $toggler-position-h:    1px;

    position: relative;
    max-height: floor($font-size-base * $font-size-small-unitless * $line-height-base) + $top-menu-padding-vertical * 2;
    padding-bottom: 0;
    overflow: hidden;

    &.expanded {
      max-height: none;
    }

    a {
      display: inline-block;
      margin-bottom: $top-menu-padding-vertical;
      white-space: nowrap;
    }

    .top-menu-toggler {
      @extend %fa-icon;
      display: block;
      position: absolute;
      top: $toggler-position-v;
      @if $sidebar-position == "left" {
        left: $toggler-position-h;
      } @else {
        right: $toggler-position-h;
      }
      color: mix($top-menu-link, $top-menu-bg, 33%);
      font-size: $fa-font-size-base;
      line-height: 1;
      user-select: none;

      &::before {
        content: $fa-var-caret-square-o-down;
        margin-right: 0;
      }

      &:hover,
      &:focus,
      &:active {
        color: mix($top-menu-link-hover, $top-menu-bg, 50%);
      }

      &.expanded {
        &::before {
          content: $fa-var-caret-square-o-up;
        }
      }

      @media screen and (min-width: $top-menu-collapse-breakpoint) {
        display: none;
      }
    }
  }

  ul {
    @include clearfix;
    margin: 0;
    padding: 0;
  }

  li {
    margin: 0 .8em 0 0;
    padding: 0;
    float: left;
    list-style-type: none;
    white-space: nowrap;
  }

  a {
    color: $top-menu-link;
    font-weight: $font-weight-bold;

    &:hover {
      color: $top-menu-link-hover;
      text-decoration: none;
    }
  }

  #loggedas {
    margin-left: 1em;
    float: right;
  }
}

#account {
  float: right;

  > ul > li {
    margin-right: 0;
    margin-left: .8em;
  }
}


//
// Header
// --------------------------------------------------

#header {
  @extend %clearfix;
  position: relative;
  background-color: $header-bg;
  color: $header-text;

  > h1 {
    padding: $header-padding-vertical $header-padding-horizontal;

    @if $use-logo {
      padding-left: $logo-image-width + $logo-position-horizontal + $logo-space;
      background-image: url("../images/logo/logo.png");
      background-repeat: no-repeat;
      background-position: $logo-position-horizontal $logo-position-vertical;

      @if $use-retina-logo {
        @include img-retina("../images/logo/logo@2x.png", $logo-image-width, $logo-image-height);
      }
    }

    .root {
      color: $header-root;
      font-weight: $font-weight-semi-bold;
    }

    .ancestor {
      font-weight: $font-weight-semi-bold;
    }

    .root,
    .ancestor {
      display: inline-block;
    }

    .current-project {
      display: inline-block;
    }
  }

  a {
    color: $header-link;
  }
}

#quick-search {
  #header & {
    margin-top: floor(($header-title-line-height + $header-padding-vertical * 2 - $input-height-base) / 2) - 1px;
    margin-right: $header-padding-horizontal;
    float: right;
    color: $header-text;
  }

  > * {
    vertical-align: top;
  }

  form {
    display: inline-block;

    input {
      width: $quick-search-width;
    }
  }

  > form > input,
  > select {
    border-color: $quick-search-border;

    &:focus {
      border-color: $quick-search-border-focus;
    }
  }

  option {
    background-color: $input-bg;
    color: $input-color;

    &[disabled] {
      color: $gray-400;
    }
  }
}

#project-jump {
  display: inline-block;

  &.expanded {
    .drdn-trigger {
      z-index: 1003;
      height: auto;
      padding-bottom: $header-padding-horizontal / 2;
      border-color: $quick-search-dropdown-bg;
      background-color: $quick-search-dropdown-bg;

      &::after {
        content: $fa-var-caret-up;
      }
    }
  }

  .drdn {
    &-trigger {
      @extend %form-field;
      @extend %fa-icon-after;
      min-width: $quick-search-width;
      border-color: $quick-search-border;

      &::after {
        content: $fa-var-caret-down;
        position: absolute;
        top: ($font-size-base / 2);
        right: $input-padding-horizontal;
      }
    }

    &-content {
      min-width: $quick-search-box-width;
      background: $quick-search-dropdown-bg;

      > .quick-search {
        padding: $header-padding-horizontal / 2;

        > input {
          width: 100%;
        }
      }
    }

    &-items {
      border-top: 1px solid $quick-search-dropdown-border;

      > a,
      > span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }

  a {
    color: $main-menu-link;

    &:hover,
    &:focus {
      background-color: $component-active-bg;
      color: $component-active-color;
      text-decoration: none;
    }
  }

  .all-projects a {
    font-weight: $font-weight-bold;
  }
}

#main-menu {
  $tabs-height: $main-menu-padding-vertical * 2 + $line-height-computed;

  clear: both;
  background-color: $main-menu-bg;
  box-shadow: inset 0 -1px $main-menu-border;
  color: $text-color;

  &.tabs {
    margin-bottom: 0;
    overflow: inherit;

    > ul {
      height: $tabs-height;

      > li {
        > a {
          height: $tabs-height;
          margin: 0;
          border: 0 none;
          border-radius: 0;
          background: transparent;
        }
      }
    }
  }

  > ul {
    @extend %clearfix;
    margin: 0;
    padding: 0 ($padding-side - $main-menu-padding-horizontal);
    list-style: none;
    color: $main-menu-link;

    > li {
      position: relative;
      float: left;

      &:hover {
        > .new-object {
          z-index: 100;
          border-bottom: 1px solid $main-menu-dropdown-bg;
        }

        > .menu-children {
          visibility: visible;
        }
      }

      > a {
        display: block;
        padding: $main-menu-padding-vertical $main-menu-padding-horizontal;
        transition: box-shadow $transition-time-long;
        color: $main-menu-link;
        line-height: $line-height-computed;
        white-space: nowrap;

        @media screen and (min-width: $screen-lg-min) {
          padding-right: $main-menu-padding-horizontal * 2;
          padding-left: $main-menu-padding-horizontal * 2;
        }

        &:hover,
        &:focus {
          background-color: $main-menu-bg-hover;
          box-shadow: inset 0 (-$main-menu-shadow-width) 0 $main-menu-shadow-hover;
          text-decoration: none;
        }

        &.selected {
          padding-bottom: $main-menu-padding-vertical - $main-menu-shadow-width;
          border-bottom: 3px solid $main-menu-shadow-active;
          background-color: $main-menu-bg-active;
          box-shadow: none;
          color: $main-menu-link-active;
          font-weight: $font-weight-semi-bold;
        }

        &.new-object {
          position: relative;
          width: $tabs-height;
          margin-right: $main-menu-padding-horizontal;
          padding-bottom: $main-menu-padding-vertical - 1px;
          border: 1px solid $main-menu-border;
          border-width: 0 1px;
          background-color: $main-menu-dropdown-bg;
          font-size: 0;

          &::before {
            @include fa-icon;
            content: $fa-var-plus;
            font-size: $fa-font-size-base;
            line-height: $line-height-computed;
            text-align: center;
          }

          &:hover,
          &:focus {
            box-shadow: none;
          }
        }
      }
    }
  }

  a {
    color: $main-menu-link;
  }

  .menu-children {
    @include nice-shadow(2);
    display: block;
    visibility: hidden;
    position: absolute;
    z-index: 1001;
    min-width: 130px;
    margin: 0 1px;
    padding: 0;
    overflow: hidden;
    list-style: none;
    transition: visibility 0ms 50ms;
    border-radius: 0 0 $border-radius-base $border-radius-base;
    background: $main-menu-dropdown-bg;

    &.visible {
      visibility: visible;
    }

    a {
      display: block;
      padding: $tab-padding-vertical ($tab-padding-horizontal * 2);
      border-top: 1px solid $main-menu-border;
      color: $main-menu-link;

      &:hover,
      &:focus {
        background-color: $component-active-bg;
        color: $component-active-color;
        text-decoration: none;
      }
    }

    > li:first-child > a {
      border: 0 none;
    }
  }

  .tabs-buttons {
    display: none !important; // stylelint-disable-line declaration-no-important
    padding-left: 0;
    border-color: $main-menu-border;
    background-color: $main-menu-bg;

    > button {
      box-sizing: border-box;
      height: $tabs-height - 1px;
      background-color: $main-menu-bg;

      &:hover {
        background-color: $main-menu-bg-hover;
      }
    }
  }

  ul + .tabs-buttons {
    display: block !important; // stylelint-disable-line declaration-no-important
  }
}
